<?php

namespace app\user\validate\user;

use think\Validate;

/**
 * 提问验证
 */
class Collection extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名'    =>    ['规则1','规则2'...]
     *
     * @var array
     */
    protected $rule = [
        'source_type' => 'require|in:video,live,offline,classes,exams,goods,topic',
        'source_id'   => 'require|number',
    ];

    protected $field = [
        'source_type' => '资源类型',
        'source_id'   => '资源',
    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名'    =>    '错误信息'
     *
     * @var array
     */
    protected $message = [
        'source_type.in' => '资源类型错误'
    ];

    /**
     * 验证场景
     */
    protected $scene = [
        'add'    => ['source_type', 'source_id'],
        'get'    => ['source_type'],
        'delete' => ['source_type', 'source_id'],
        'batch'  => ['ids', 'source_type'],
    ];

}
